<?php	
	include "includes".DIRECTORY_SEPARATOR."start_session.php";
	

	if ( !defined('USERNAME') || !defined('GROUP') || GROUP != "anc")
	{
		header("Location: manage_login.php");
		exit;
	}
	
	
			
	include "includes".DIRECTORY_SEPARATOR."header.php";
	main_header(1);

	//include second header

	include "includes".DIRECTORY_SEPARATOR."include_user_secondary_header.php";
	second_header( 1 );

 ?>
 
<tr>
    <td colspan="2" valign="top">
            <h2 style="margin-left:30px">Bine&nbsp;ai&nbsp;venit,&nbsp&nbsp<?php echo USERNAME." !"; ?>
            </h2>
    </td>
</tr>   


<?php		  
  
/* 	 VIEW MANUFACTURER */

   if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['view_furnizor']) and isset($_GET['cui_furnizor']))
   {
        echo "<tr>";
            echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
            echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
			echo "<h3>CUI/CF Furnizor: $_GET[cui_furnizor]</h3>";
            echo "<h4>Vizualizare date furnizor: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_manufacturer.php";
            echo "</td>";       
		echo "</tr>";

		$local_cui_furnizor = $_GET['cui_furnizor'];
		$get_form_decizie_furnizor=<<<GATA
			<form method="post" action = "user_anc_list_notifications.php">
					<table border = 0 style="margin-left:35px;"> 
					<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
					<tr><td><input type ="submit" name="aprobare_furnizor" value = "Aproba" >
							<input type ="submit" name="respingere_furnizor" value = "Respinge" ></td></tr>
					<input type="hidden" name="cui_furnizor" value="$local_cui_furnizor"> 
					</table>
			</form>
GATA;
		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $get_form_decizie_furnizor;
			echo "</td>";
		echo "</tr>";

   }
   else if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['view_furnizor']) and isset($_POST['cui_furnizor']))
   {
        echo "<tr>";
            echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
            echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
			echo "<h3>CUI/CF Furnizor: $_POST[cui_furnizor]</h3>";
            echo "<h4>Vizualizare date furnizor: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_manufacturer.php";
            echo "</td>";
        echo "</tr>";

		$local_cui_furnizor = $_POST['cui_furnizor'];
		$post_form_decizie_furnizor=<<<GATA
			<form method="post" action = "user_anc_list_notifications.php">
					<table border = 0 style="margin-left:35px;"> 
					<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
					<tr><td><input type ="submit" name="aprobare_furnizor" value = "Aproba" >
							<input type ="submit" name="respingere_furnizor" value = "Respinge" ></td></tr>
					<input type="hidden" name="cui_furnizor" value="$local_cui_furnizor"> 
					</table>
			</form>
GATA;
		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $post_form_decizie_furnizor;
			echo "</td>";
		echo "</tr>";
   }
   
   /* EDIT PROGRAM */

   else  if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['view_program']) and isset($_GET['cui_furnizor']) and isset($_GET['id_program']))
   {
        echo "<tr>";
        echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
            echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
            echo "<h3>CUI/CF Furnizor: $_GET[cui_furnizor] | Program: $_GET[id_program] </h3>";
            echo "<h4>Modifica program: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_program.php";
            echo "</td>";       
        echo "</tr>";
		
	$local_cui_furnizor = $_GET['cui_furnizor'];
	$local_id_program = $_GET['id_program'];
	
	$get_form_decizie_program=<<<GATA
	<form method="post" action = "user_anc_list_notifications.php">
			<table border = 0 style="margin-left:35px;"> 
			<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
			<tr><td><input type ="submit" name="aprobare_program" value = "Aproba" >
					<input type ="submit" name="respingere_program" value = "Respinge" ></td></tr>
			<input type="hidden" name="cui_furnizor" value="$local_cui_furnizor"> 
			<input type="hidden" name="id_program" value="$local_id_program"> 
			</table>
	</form>
GATA;
		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $get_form_decizie_program;
			echo "</td>";
		echo "</tr>";
   }
   else  if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['view_program']) and isset($_POST['cui_furnizor']) and isset($_POST['id_program']))
   {
        echo "<tr>";
        echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
            echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
            echo "<h3>CUI/CF Furnizor: $_POST[cui_furnizor] | Program: $_POST[id_program] </h3>";
            echo "<h4>Modifica program: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_program.php";
            echo "</td>";       
        echo "</tr>";

	$local_cui_furnizor = $_POST['cui_furnizor'];
	$local_id_program = $_POST['id_program'];

	$post_form_decizie_program=<<<GATA
	<form method="post" action = "user_anc_list_notifications.php">
			<table border = 0 style="margin-left:35px;"> 
			<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
			<tr><td><input type ="submit" name="aprobare_program" value = "Aproba" >
					<input type ="submit" name="respingere_program" value = "Respinge" ></td></tr>
			<input type="hidden" name="cui_furnizor" value="$local_cui_furnizor"> 
			<input type="hidden" name="id_program" value="$local_id_program"> 
			</table>
	</form>
GATA;
		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $post_form_decizie_program;
			echo "</td>";
		echo "</tr>";
		
   }
   
   /* EDIT SESSION */
   
   else  if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['view_sesiune']) and isset($_GET['id_program']) and isset($_GET['id_sesiune']))
   {
        echo "<tr>";
        echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
            echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
            echo "<h3>Program: $_GET[id_program] | Sesiune: $_GET[id_sesiune]</h3>";
            echo "<h4>Vizualizare date sesiune: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_session.php";
            echo "</td>";       
        echo "</tr>";
		
	$local_id_sesiune = $_GET['id_sesiune'];
	$local_id_program = $_GET['id_program'];		
		
	$get_form_decizie_sesiune=<<<GATA
	<form method="post" action = "user_anc_list_notifications.php">
			<table border = 0 style="margin-left:35px;"> 
			<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
			<tr><td><input type ="submit" name="aprobare_sesiune" value = "Aproba" >
					<input type ="submit" name="respingere_sesiune" value = "Respinge" ></td></tr>
					<input type="hidden" name="id_sesiune" value="$local_id_sesiune"> 
					<input type="hidden" name="id_program" value="$local_id_program"> 
			</table>
	</form>
GATA;

		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $get_form_decizie_sesiune;
			echo "</td>";
		echo "</tr>";
   }
   else  if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['view_sesiune'])  and isset($_POST['id_program']) and isset($_POST['id_sesiune']))
   {
        echo "<tr>";
        echo "<td style=\"padding-left:30;padding-right:20;padding-bottom:20\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
			echo "<a href=\"user_anc_list_notifications.php\"><img src=\"images/back_icon.png\" alt=\"ANC\"/></a>";
            echo "<h3>Program: $_GET[id_program] | Sesiune: $_GET[id_sesiune]</h3>";
            echo "<h4>Modificare date sesiune: </h4>";
            include "includes".DIRECTORY_SEPARATOR."include_user_session.php";
            echo "</td>";       
        echo "</tr>";
		
		$local_id_sesiune = $_POST['id_sesiune'];
		$local_id_program = $_POST['id_program'];		
		
	$post_form_decizie_sesiune=<<<GATA
	<form method="post" action = "user_anc_list_notifications.php">
			<table border = 0 style="margin-left:35px;"> 
			<tr><td><textarea rows="5" cols="60" name="mesaj_anc" title="Introduceti comentariul dumneavoastra" id="styled" onFocus="if (this.value == this.defaultValue) { this.value = ''; }">Introduceti comentariul dumneavoastra</textarea></td></tr>
			<tr><td><input type ="submit" name="aprobare_sesiune" value = "Aproba" >
					<input type ="submit" name="respingere_sesiune" value = "Respinge" ></td></tr>
					<input type="hidden" name="id_sesiune" value="$local_id_sesiune"> 
					<input type="hidden" name="id_program" value="$local_id_program"> 
			</table>
	</form>
GATA;

		echo "<tr>";
			echo "<td align=\"center\">";	
				echo $post_form_decizie_sesiune;
			echo "</td>";
		echo "</tr>";	
   } 
   else
   {		if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['cui_furnizor']) and ( isset($_POST['aprobare_furnizor']) or isset($_POST['respingere_furnizor'])))
   			{				
				$state = "";
				if( isset($_POST['aprobare_furnizor']) )
				{
					$state = "aprobat_anc";
				}
				else if( isset($_POST['respingere_furnizor']))
				{
					$state = "respins_anc";
				}
				
				$mesaj = "";
				if ( empty( $_POST['mesaj_anc']) )
				{
					$mesaj  =  "nu exista comentarii";
				}
				else
				{
					if ( strlen( $_POST['mesaj_anc'] ) < 500 )
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = trim($mesaj);
					}
					else
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = substr($description, 0, 498);	
					}
				}
				
				$var_cui_furnizor = $_POST['cui_furnizor'];
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `furnizor` SET `state_anc`='$state',`comentarii`='$mesaj' WHERE `CUI_CF`='$var_cui_furnizor'");
   			}
			
			else if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['cui_furnizor']) and isset($_POST['id_program']) and ( isset($_POST['aprobare_program']) or isset($_POST['respingere_program'])))
   			{
	   			if( isset($_POST['aprobare_program']) )
				{
					$state = "aprobat_anc";
				}
				else if( isset($_POST['respingere_program']))
				{
					$state = "respins_anc";
				}
				
				$mesaj = "";
				if ( empty( $_POST['mesaj_anc']) )
				{
					$mesaj  =  "nu exista comentarii";
				}
				else
				{
					if ( strlen( $_POST['mesaj_anc'] ) < 500 )
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = trim($mesaj);
					}
					else
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = substr($description, 0, 498);	
					}
				}
				
				$var_cui_furnizor = $_POST['cui_furnizor'];
				$var_id_program = $_POST['id_program'];
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `furnizori_programe` SET `state_anc`='$state' `comentarii`='$mesaj' WHERE `CUI_CF`='$var_cui_furnizor' AND `id_furnizori_programe`='$var_id_program'");
				
   			}
			
			else if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['id_program']) and isset($_POST['id_sesiune']) and ( isset($_POST['aprobare_sesiune']) or isset($_POST['respingere_sesiune'])))
   			{
	   			if( isset($_POST['aprobare_sesiune']) )
				{
					$state = "'aprobat_anc'";
				}
				else if( isset($_POST['respingere_sesiune']))
				{
					$state = "'respins_anc'";
				}
				
				$mesaj = "";
				if ( empty( $_POST['mesaj_anc']) )
				{
					$mesaj  =  "nu exista comentarii";
				}
				else
				{
					if ( strlen( $_POST['mesaj_anc'] ) < 500 )
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = trim($mesaj);
					}
					else
					{
						$mesaj = $_POST['mesaj_anc']; 
						$mesaj = substr($description, 0, 498);	
					}
				}
				
				$var_cui_furnizor = $_POST['cui_furnizor'];
				$var_id_program = $_POST['id_program'];
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `furnizori_programe` SET `state_anc`='$state',`comentarii`='$mesaj' WHERE `CUI_CF`='$var_cui_furnizor' AND `id_furnizori_programe`='$var_id_program'");
   			}
			
			else if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['aprobare_furnizor']) and isset($_GET['cui_furnizor']))
			{
				if($_GET['aprobare_furnizor'] == "true")
					$state = "'aprobat_anc'";
				else
					$state = "'respins_anc'";
				$var_cui_furnizor = $_GET['cui_furnizor'];
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `furnizor` SET `state_anc`=".$state." WHERE `CUI_CF`='$var_cui_furnizor'");
			}
			else if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['aprobare_program']) and isset($_GET['cui_furnizor']) and isset($_GET['id_program']))
			{
				if($_GET['aprobare_program'] == "true")
					$state = "'aprobat_anc'";
				else
					$state = "'respins_anc'";
				$var_cui_furnizor = $_GET['cui_furnizor'];
				$var_id_program = $_GET['id_program'];
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `furnizori_programe` SET `state_anc`=".$state." WHERE `CUI_CF`='$var_cui_furnizor' AND `id_furnizori_programe`='$var_id_program'");
			}
			else if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['aprobare_sesiune']) and isset($_GET['id_program']) and isset($_GET['id_sesiune']))
			{
				if($_GET['aprobare_sesiune'] == "true")
					$state = "'aprobat_anc'";
				else
					$state = "'respins_anc'";
				$var_id_sesiune = $_GET['id_sesiune'];
				$var_id_program = $_GET['id_program'];	
				$query_update_status_furnizori= mysqli_query( $dbc, "UPDATE `sesiuni` SET `state_anc`=".$state." WHERE `id_sesiune`=$var_id_sesiune AND `id_furnizori_programe`=$var_id_program");
			}
   
	         echo "<tr>";
    			echo "<td  colspan=\"2\" style=\"padding-left:30;padding-right:20;\" valign=\"top\" background=\"images/white.jpg\" width=\"800\" height=\"400\">";
                    echo "<table class=\"zebra-style\">";
				      include "includes".DIRECTORY_SEPARATOR."include_user_anc_list_notifications.php";	
                    echo "</table>";
             echo "</td>";       
           echo "</tr>";
   }
?>
           
<?php
	include "includes".DIRECTORY_SEPARATOR."footer.php";
?>
     
     